package entity;


/**
 * @author 李民康
 * @date 2021/6/16 21:36
 * 公共返回对象
 */
public class ResBean {
    private boolean flag;//是否成功
    private Integer code;//返回码
    private String message;//返回消息
    private Object data;//返回数据

    public static ResBean success(String message) {
        return new ResBean(true,StatusCode.OK,message,null);
    }

    public static ResBean success(String message, Object data) {
        return new ResBean(true,StatusCode.OK,message,data);
    }

    public static ResBean success(String message,Integer code,Object data) {
        return new ResBean(true,code,message,data);
    }

    public static ResBean error(String message) {
        return new ResBean(false,StatusCode.ERROR,message,null);
    }

    public static ResBean error(String message, Object data) {
        return new ResBean(false,StatusCode.ERROR,message,data);
    }

    public static ResBean error(String message,Integer code, Object data) {
        return new ResBean(false,code,message,data);
    }




    public ResBean(boolean flag,Integer code, String message, Object data) {
        this.flag=flag;
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ResBean() {
    }

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
